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
;		 THE ADVENTURE PROTECTION MODULE - PROTECT.ASM

	 EXTRN	 CHKCOPY:NEAR

	 PUBLIC  INDARK,	 DS_SAVE,	 REPLY
	 PUBLIC  ZVIDMODE,	 ZPALETTE
	 public  OldInt08

BEGIN	 PROC  FAR
	 ASSUME CS:CODE,ES:VIDEO,SS:STKSEG
	 ASSUME DS:ABS0
	 JMP   SHORT SKIP_VAR
ZVIDMODE DB    04		  ;DEFAULT 320X200 COLOR MODE
ZPALETTE DB    01		  ;DEFAULT CYAN/MAGENTA/WHITE PALETTE
ZRESTART DB    00		  ;01 IF THIS IS A GAME RESTART
OldInt08 dd    ?
SKIP_VAR:
	 ASSUME DS:DATA
	 MOV   AX,VIDEO
	 MOV   ES,AX
	 MOV   AX,DATA
	 MOV   DS,AX
	 DISABLE
	 MOV   CS:DS_SAVE,AX
	 push  es
	 mov   ax,3508h
	 int   21h
	 mov   word ptr cs:OldInt08,bx
	 mov   word ptr cs:OldInt08+2,es
	 pop   es
	 PUSH  DS		  ;INSERT CHKANT AS TIMER INTERRUPT
	 MOV   AX,CS
	 MOV   DS,AX
	 MOV   DX,OFFSET CHKANT
	 MOV   AX,2508H
	 INT   21H
	 MOV   DX,OFFSET DSKERR   ;INSERT DISK CRITICAL ERROR RTN
	 MOV   AX,2524H
	 INT   21H
	 POP   DS
NEWGAM:
	 MOV   BX,OFFSET STARTVAR ;INIT ALL VARIABLES
	 MOV   CX,ENDVAR-STARTVAR-1
	 MOV   AL,0
BEGIN_A:
	 MOV   [BX],AL
	 INC   BX
	 LOOP  BEGIN_A
;
;	 CHECK FOR PROTECTION SCHEME
;
	 CALL  CHKCOPY
;
;	 INITIALIZE THE ROOM DIRECTION & OBJECT TABLES
;
	 PUSH  ES
	 MOV   SI,OFFSET RMTBDF
	 PUSH  DS
	 POP   ES
	 MOV   DI,OFFSET ROOMTB
	 MOV   CX,RMTB_LEN
	 CLD
	 REP   MOVSB
	 POP   ES
;
;	 INITIALIZE THE GRAPHIC PIXEL CONVERSION TABLE
;
	 MOV   BX,OFFSET GPC_TAB
	 MOV   CL,0
BEGIN_D:
	 MOV   AL,CL
	 CALL  BIT_EXPL
	 MOV   [BX],AX
	 INC   BX
	 INC   BX
	 INC   CL
	 JNZ   BEGIN_D
;
;	 ADVENTURE UNIQUE INITIALIZATION
;
	 MOV   LITECT,35

;
;	 INIT VIDEO MODE
;
	 INIT_VIDEO
	 TEST  ZRESTART,0FFH
	 JNZ   GET_MON2
	 INC   ZRESTART
	 CALL  CLS
	 MOV   BX,OFFSET MON_MSG
	 CALL  DISPLY
GET_MON1:
	 SCANKEY
	 JZ    GET_MON1
	 GETKEY
	 CMP   AL,'1'
	 JB    GET_MON1
	 CMP   AL,'3'
	 JA    GET_MON1
	 JE    GET_MON2
	 MOV   ZVIDMODE,5
	 INIT_VIDEO
GET_MON2:
	 CALL  CLS
	 MOV   CX,10000
BEGIN_DELAY:
	 LOOP  BEGIN_DELAY
	 MOV   AL,1
	 CALL  SHOOVL
	 MOV   SI,OFFSET MDLOGO
	 CALL  SHOSCR
	 MOV   ROW,23
	 MOV   COL,0
	 LEA   BX,VERSN
	 CALL  DISPLY
	 MOV   ROW,2
	 MOV   COL,15
	 LEA   BX,MDPCRE
	 CALL  DISPLY
	 MOV   ROW,15
	 MOV   COL,0
	 LEA   BX,CREDIT
	 CALL  DISPLY
BEGIN_B:
	 INC   RANDOM
	 INC   FLIPCT
	 MOV   AX,FLIPCT
	 CMP   AX,6000
	 JB    BEGIN_C
	 MOV   FLIPCT,0
	 CALCX 70,13
	 CALCD 70,13,85,112
	 MOV   COLOR1,RED
	 MOV   COLOR2,WHITE
	 CALL  FLPCLR
BEGIN_C:
	 SCANKEY
	 JZ    BEGIN_B
	 GETKEY
	 MOV   ROOM,1
	 CALL  CLS
	 JMP   VLOOK
BEGIN	 ENDP

DS_SAVE  DW    ?

;
;	 FILE: ADVINIT.ASM
;
